package com.xdk.templatescala.service.impl;

import com.xdk.templatescala.common.enums.ScaleFillEnum;
import com.xdk.templatescala.common.enums.ScaleStatusEnum;
import com.xdk.templatescala.common.enums.ScaleTypeEnum;
import com.xdk.templatescala.common.response.Page;
import com.xdk.templatescala.dao.ScaleDao;
import com.xdk.templatescala.model.ScaleEntry;
import com.xdk.templatescala.service.ScaleService;
import com.xdk.templatescala.utils.DateUtils;
import com.xdk.templatescala.utils.uuid.IdUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class ScaleServiceImpl implements ScaleService {

    @Autowired
    private ScaleDao scaleDao;

    @Override
    public Page<ScaleEntry> findScaleEntryByParam(Integer pageNum, Integer pageSize) {
        return scaleDao.findAll(pageNum, pageSize);
    }

    @Override
    public ScaleEntry findScaleEntry(String scaleId) {
        return scaleDao.findOne(scaleId);
    }

    @Override
    public Long delScales(String scaleIds) {
        return scaleDao.delScales(scaleIds);
    }

    @Override
    public Long updateScale(ScaleEntry scaleEntry) {
        return scaleDao.updateScales(scaleEntry);
    }

    @Override
    public ScaleEntry addScaleEntry(ScaleEntry scaleEntry) {
        scaleEntry.setScaleId(IdUtils.fastSimpleUUID());
        scaleEntry.setStatus(ScaleStatusEnum.SCALE_STATUS_1.getCode());
        scaleEntry.setCreateTime(DateUtils.getTime());
        scaleEntry.setUpdateTime(DateUtils.getTime());
        scaleDao.addScaleEntry(scaleEntry);
        return scaleEntry;
    }

}
